package com.itheima.Demo01;

public abstract class Employee {
    private String name;//姓名
    private String workId;//工作id
    private String dept;//部门

    public Employee() {
    }

    public Employee(String name, String workId, String dept) {
        this.name = name;
        this.workId = workId;
        this.dept = dept;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWorkId() {
        return workId;
    }

    public void setWorkId(String workId) {
        this.workId = workId;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

    public abstract void showMsg();
}
/*------------------------------------------------------*/
class Manager extends Employee{
    private  Clerk clerk;

    public Manager() {
    }

    public Manager(String name, String workId, String dept, Clerk clerk) {
        super(name, workId, dept);
        this.clerk = clerk;
    }

    public Clerk getClerk() {
        return clerk;
    }

    public void setClerk(Clerk clerk) {
        this.clerk = clerk;
    }//直接获取需要的员工地址（这样在经理类中有更改clerk的方法的话
                                                             // 就会更改外面那个传进来的clerk值）也可以在这里面new一个新的，然后赋值
                                                             //这样更改clerk就不会更改外卖clerk的值

    @Override
    public void showMsg() {
        System.out.println("这是经理，TA叫"+getName()+" TA的工号是"+getWorkId()+" TA的部门是"+getDept()+" 他的员工是"+getClerk().getName());
    }
}
/*------------------------------------------------------*/
class Clerk extends Employee{
    private Manager manager;

    public Clerk() {
    }
    public Clerk(String name,String workId, String dept,Manager manager){
        super(name,workId,dept);
        this.manager=manager;
    }

    public Manager getManager() {
        return manager;
    }

    public void setManager(Manager manager) {
        this.manager = manager;
    }

    @Override
    public void showMsg() {
        System.out.println("这是员工,TA叫"+getName()+" TA的工号是"+getWorkId()+" TA的部门是"+getDept()+" 他的经理是"+getManager().getName());
    }
}
/*------------------------------------------------------*/
class test{
    public static void main(String[] args) {
        Manager manager=new Manager("杨经理","1321","开发",null);
        Clerk clerk=new Clerk("张老","231","开发",null);

        manager.setClerk(clerk);
        clerk.setManager(manager);

        clerk.showMsg();
        manager.showMsg();
    }
}